//
//  HMVisitorTableViewController.swift
//  Weibo
//
//  Created by 吴少飞 on 16/9/20.
//  Copyright © 2016年 wushaofei. All rights reserved.
//

import UIKit

class HMVisitorTableViewController: UITableViewController {

    var isLogin: Bool = HMUserAccountViewModel.sharedUserAccountViewModel.isLogin
    
    var vistorView : HMVisitorView?
    
    override func loadView() {
        
        if isLogin == true {
            
            super.loadView()
        }else{
            
            vistorView = HMVisitorView()
            
            vistorView?.startLogging = { [weak self] in
                
                
                self?.OAuthLoging()
                
            }
            view = vistorView
            addNavItem()
        }
                
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }
    
    func addNavItem(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: #selector(logingAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: #selector(logingAction))

    }
    
    func logingAction(){
        
        
        OAuthLoging()
        
        
    }
    
    //OAU登录
    func OAuthLoging(){
        
        let oauVC = HMOAuthViewController()
        
        let navVC = HMNavigationController(rootViewController: oauVC)
        
        present(navVC, animated: true, completion: nil)
        
        
    }
    
    
    
}
